<?php
function entity_import_lookup_term_name_as_tid(Infinity\Entity &$entity, $field, array $value, array $field_data) {
  $tid = Infinity\Query::select('taxonomy_term', 't', ['name' => $value[0], 'vid' => 1], [])
    ->fields('t', ['tid'])
    ->execute()
    ->fetchField();
  if(!$tid) {
    $term = new Infinity\Entity('taxonomy_term', [
      'vid' => 1,
      'name' => $value[0]
    ]);
    $term->save();
    $tid = $term->tid;
  }
  $entity->fieldManager()->setValue($field, 'tid', $tid);
}